home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++,de.comp.lang.c++
- Path: Dortmund.Germany.EU.net!oerag!snark!KEN
- From: KEN@oerag.de (Karsten Ensinger)
- Subject: Re: Another function pointer from a class question?!
- References: <4jls2p$bac@pulp.ucs.ualberta.ca>
- Date: 01 Apr 1996 14:14:05 GMT
- Message-ID: <KEN.96Apr01141405@oerag.de>
- In-reply-to: ryangall@gpu.srv.ualberta.ca's message of 31 Mar 1996 11:59:21 GMT
- X-NNTPDaemon: changi 0.9 for OS/2
-
- Hi Ryan!
-
- First: you can not redefine Remove as a function taking NO argument.
- In list: virtual T Remove(T)=0;
- In dl_list: T Remove(); -> This hides the virtual T Remove(T)!
-
- Second: the return value of list<T>::Add(T) is "T" but the return
- value of dl_list<T>::Add(T) is "int". Same problem as "First:" if
- you use dl_list<T> with types other than int.
-
- Third: you have to implement ALL pure virtual functions of your
- baseclass (list) if you want to create a object of this
- class (dl_list).
- So you have to implement in dl_list also "int isempty()" and
- "int Inlist(T)". If you don't (and you didn't ;-)) you have another
- abstract class which cannot be created. This is what the compiler
- complains about "abstract class".
-
- The error message of the linker is caused by NOT inheriting from
- list<T> but implementing only "list<T>::print(...)". You should
- also implement "dl_list<T>::print(...)".
-
- My suggestion is:
- try to implement ALL methods of list<T> in dl_list<T> and always
- have a look at the warnings of the compiler. For a beginner I
- would recommend to use a high warning level (but not the highest!).
-
- Regards
- Karsten
-